package org.ccay.core.support.session;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统状态持有者，仅保存于内存中
 * 
 * @author chaowangbang
 *
 */
public final class SystemStateHolder {
	
	/**
	 * 在线Session数的KEY
	 */
	public static final String ONLINE_USER_COUNT = "CCAY_OLINE_COUNT";
	
	
	private SystemStateHolder(){
	}
	
	private static Map<String,Object > stateMap  = new HashMap<String, Object>();
	
	/**
	 * 设置值
	 * @param key
	 * @param value
	 */
	public static void put(String key, Object value){
		stateMap.put(key, value);
	}
	
	/**
	 * 获取值
	 * @param key
	 * @return
	 */
	public static Object get(String key, Object defaultValue){
		Object obj = stateMap.get(key);
		
		if(obj == null){
			return defaultValue;
		}
		
		return obj;
	}
}
